package app.com.business.dao.impl;

import java.util.List;

import org.springframework.orm.hibernate3.HibernateObjectRetrievalFailureException;

import app.com.business.bo.Etat;
import app.com.business.dao.EtatDao;
import app.com.business.exceptions.MaterielException;

import com.groupeA.dao.impl.GenericDaoImpl;

public class EtatDaoImpl extends GenericDaoImpl<Etat, Long> implements EtatDao{

	public EtatDaoImpl() {
		super(Etat.class);
	}

	public Etat getEtatByType(String typeEtat) throws MaterielException{
		try {
			List etats =  getHibernateTemplate().find("from Etat where type = ?", typeEtat);
			if(etats == null | etats.size() == 0 | etats.get(0) == null){
				throw new MaterielException();
			}
			return (Etat)etats.get(0) ;
			}catch(HibernateObjectRetrievalFailureException ex)
			{
				throw new MaterielException();
			}
	}

}
